﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Text;
using System.Security.Cryptography;

/// <summary>
/// UnicomService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
[System.Web.Script.Services.ScriptService]
public class UnicomService : System.Web.Services.WebService
{

    public UnicomService()
    {
        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public Clerkinfo UserLogin(string uname,string upwd) {
        Clerkinfo ci = new Clerkinfo();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from clerkinfo where  CLERKNO='" + uname + "' and CLERKPWD='" + upwd + "'");
        int i = query.Tables[0].Rows.Count;
        if (i > 0)
        {
            oledb.executeSql("update clerkinfo set CREATETIME='" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "'  where  CLERKNO='" + uname + "' and CLERKPWD='" + upwd + "'");

            ci.ID = int.Parse(query.Tables[0].Rows[0]["ID"].ToString());
            ci.CLERKNO = query.Tables[0].Rows[0]["CLERKNO"].ToString();
            ci.CNAME = query.Tables[0].Rows[0]["CNAME"].ToString();
            ci.CDEPT = query.Tables[0].Rows[0]["CDEPT"].ToString();
            ci.CREATETIME= query.Tables[0].Rows[0]["CREATETIME"].ToString();
            ci.FLAG = int.Parse(query.Tables[0].Rows[0]["FLAG"].ToString());
        }
        return ci;
    }

    [WebMethod]
    public List<Setmenus> GetAllSetmenus() {
        List<Setmenus> lsm = new List<Setmenus>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from setmenus ").Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            Setmenus sm = new Setmenus();
            sm.ID = int.Parse(query.Rows[i]["ID"].ToString());
            sm.SDATE = query.Rows[i]["SDATE"].ToString();
            sm.SDATEEND = query.Rows[i]["SDATEEND"].ToString();
            sm.SFLOW = int.Parse(query.Rows[i]["SFLOW"].ToString());
            sm.SNAME = query.Rows[i]["SNAME"].ToString();
            sm.SPRICE = int.Parse(query.Rows[i]["SPRICE"].ToString());
            sm.STIME = int.Parse(query.Rows[i]["STIME"].ToString());

            lsm.Add(sm);
        }
        return lsm;
    }

    [WebMethod]
    public List<Setflows> GetAllSetflows()
    {
        List<Setflows> lsf = new List<Setflows>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from setflows ").Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            Setflows sf = new Setflows();
            sf.ID = int.Parse(query.Rows[i]["ID"].ToString());
            sf.FPRICE = int.Parse(query.Rows[i]["FPRICE"].ToString());
            sf.FNAME = query.Rows[i]["FNAME"].ToString();
            sf.FFLOW = int.Parse(query.Rows[i]["FFLOW"].ToString());
            sf.FDATEEND = query.Rows[i]["FDATEEND"].ToString();
            sf.FDATE = (query.Rows[i]["FDATE"].ToString());

            lsf.Add(sf);
        }
        return lsf;
    }

    [WebMethod]
    public List<Cruise> GetAllCruise()
    {
        List<Cruise> lsf = new List<Cruise>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from cruise ").Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            Cruise sf = new Cruise();
            sf.ID = int.Parse(query.Rows[i]["ID"].ToString());
            sf.CUAREA =query.Rows[i]["CUAREA"].ToString();
            sf.CUFLOW =  int.Parse(query.Rows[i]["CUFLOW"].ToString());
            sf.CULAST = int.Parse(query.Rows[i]["CULAST"].ToString());
            sf.CUNAME = query.Rows[i]["CUNAME"].ToString();
            sf.CUPRICE = int.Parse(query.Rows[i]["CUPRICE"].ToString());
            sf.CUTIMEPRICE = float.Parse(query.Rows[i]["CUTIMEPRICE"].ToString());

            lsf.Add(sf);
        }
        return lsf;
    }

    [WebMethod]
    public List<Phoneinfo> GetAllAvailablePCodes()
    {
        List<Phoneinfo> lp = new List<Phoneinfo>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from phoneinfo  where PSTATUS='无主'").Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            Phoneinfo p = new Phoneinfo();
            p.ID = int.Parse(query.Rows[i]["ID"].ToString());
            p.PBALANCE = int.Parse(query.Rows[i]["PBALANCE"].ToString());
            p.PCRUISE = query.Rows[i]["PCRUISE"].ToString();
            p.PCRUID = int.Parse(query.Rows[i]["PCUID"].ToString());
            p.PCRUISEBEGIN = query.Rows[i]["PCRUISEBEGIN"].ToString();
            p.PENDTIME = (query.Rows[i]["PENDTIME"].ToString());
            p.PFID = int.Parse(query.Rows[i]["PFID"].ToString());
            p.PFLOW = int.Parse(query.Rows[i]["PFLOW"].ToString());
            p.PINITIME = (query.Rows[i]["PINITIME"].ToString());
            p.PNO = query.Rows[i]["PNO"].ToString();
            p.PSCORE = int.Parse(query.Rows[i]["PSCORE"].ToString());
            p.PSID = int.Parse(query.Rows[i]["PSID"].ToString());
            p.PSTATUS = query.Rows[i]["PSTATUS"].ToString();
            p.PTIME = int.Parse(query.Rows[i]["PTIME"].ToString());
            p.PUID = int.Parse(query.Rows[i]["PUID"].ToString());
            p.PREMARK = (query.Rows[0]["PREMARK"].ToString());
            p.PFTIME = (query.Rows[0]["PFTIME"].ToString());
            p.PMTIME = (query.Rows[0]["PMTIME"].ToString());

            lp.Add(p);
        }
        return lp;
    }

    [WebMethod]
    public int addNewUser(string UNAME,string UIDNO, string UIDENDTIME, string UEMAIL, string UGENDER, string UBIRTH, string UADDRESS,int PID,int PSMID,int PSFID,string BCONTENT,string BSMARK,string BFMARK,int CID,int BAMOUNT) {
        string sql = "insert into userinfo(UNAME,UIDNO,UIDENDTIME,UEMAIL,UGENDER,UBIRTH,UADDRESS,UCREATETIME) "+
            " values('"+UNAME.Replace("'","‘")+"','"+UIDNO.Replace("'", "‘") + "','"+UIDENDTIME+"','"+UEMAIL.Replace("'", "‘") + "','"+UGENDER+"','"+UBIRTH+"','"+UADDRESS.Replace("'", "‘") + "','"+DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString()+"')";
        OleDB oledb = new OleDB();
        if (oledb.executeSql(sql))
        {
            int id = oledb.getIntegerValue("select ID from userinfo order by ID desc LIMIT 1");
            int calltime = oledb.getIntegerValue("select STIME from setmenus where ID="+ PSMID);
            int callflow = oledb.getIntegerValue("select SFLOW from setmenus where ID=" + PSMID);
            int flow = 0;
            if (PSFID != 0)
            {
                flow = oledb.getIntegerValue("select FFLOW from setflows where ID=" + PSFID);
            }
            string sql2 = "update phoneinfo set PSTATUS='正常' ,PUID="+id+ ", PSID="+ PSMID+ ", PFID="+ PSFID+ ", PTIME="+calltime+" ,PFLOW="+(callflow+flow)+", PINITIME='"+ DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "' where ID="+PID;
            if (oledb.executeSql(sql2)) {
                oledb.executeSql("insert into business(BDATE,BCONTENT,BUID,BPID,BSID,BSMARK,BFID,BFMARK,BCID,BAMOUNT) "+
                    " values('"+ DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "'," +
                    "'"+BCONTENT+"',"+id+","+PID+","+PSMID+",'"+ BSMARK + "',"+PSFID+",'"+ BFMARK + "',"+ CID + ","+ BAMOUNT + ")");
                return id;
            }
            else
            {
                oledb.executeSql("delete from userinfo where ID="+id);
                return 0;
            }
        }
        else
        {
            return 0;
        }
    }

    [WebMethod]
    public int GetFare(int id,int type) {
        OleDB oledb = new OleDB();
        if (type==1) {
            return oledb.getIntegerValue("select SPRICE from setmenus where ID="+id);
        }
        else if(type==2)
        {
            return oledb.getIntegerValue("select FPRICE from setflows where ID=" + id);
        }
        else
        {
            return 0;
        }
    }

    [WebMethod]
    public List<UserPhone> GetAllUserPhone() {
        List<UserPhone> lup = new List<UserPhone>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from userphone").Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            UserPhone up = new UserPhone();
            up.phoneinfo_ID = query.Rows[i]["ID"].ToString();
            up.phoneinfo_PBALANCE = query.Rows[i]["PBALANCE"].ToString();
            up.phoneinfo_PCRUISE = query.Rows[i]["PCRUISE"].ToString();
            up.phoneinfo_PCUID = query.Rows[i]["PCUID"].ToString();
            up.phoneinfo_PCRUISEBEGIN = query.Rows[i]["PCRUISEBEGIN"].ToString();
            up.phoneinfo_PENDTIME = query.Rows[i]["PENDTIME"].ToString();
            up.phoneinfo_PFID = query.Rows[i]["PFID"].ToString();
            up.phoneinfo_PFLOW = query.Rows[i]["PFLOW"].ToString();
            up.phoneinfo_PINITIME = query.Rows[i]["PINITIME"].ToString();
            up.phoneinfo_PNO = query.Rows[i]["PNO"].ToString();
            up.phoneinfo_PSCORE = query.Rows[i]["PSCORE"].ToString();
            up.phoneinfo_PSID = query.Rows[i]["PSID"].ToString();
            up.phoneinfo_PSTATUS = query.Rows[i]["PSTATUS"].ToString();
            up.phoneinfo_PTIME = query.Rows[i]["PTIME"].ToString();
            up.phoneinfo_PUID = query.Rows[i]["PUID"].ToString();
            up.setflows_FNAME = query.Rows[i]["FNAME"].ToString();
            up.setflows_ID = query.Rows[i]["FID"].ToString();
            up.setmenus_ID = query.Rows[i]["SID"].ToString();
            up.setmenus_SNAME = query.Rows[i]["SNAME"].ToString();
            up.userinfo_FLAG = query.Rows[i]["FLAG"].ToString();
            up.userinfo_ID = query.Rows[i]["UID"].ToString();
            up.userinfo_UADDRESS = query.Rows[i]["UADDRESS"].ToString();
            up.userinfo_UBIRTH = query.Rows[i]["UBIRTH"].ToString();
            up.userinfo_UCREATETIME = query.Rows[i]["UCREATETIME"].ToString();
            up.userinfo_UEMAIL = query.Rows[i]["UEMAIL"].ToString();
            up.userinfo_UGENDER = query.Rows[i]["UGENDER"].ToString();
            up.userinfo_UIDENDTIME = query.Rows[i]["UIDENDTIME"].ToString();
            up.userinfo_UIDNO = query.Rows[i]["UIDNO"].ToString();
            up.userinfo_UNAME = query.Rows[i]["UNAME"].ToString();
            up.setflows_FFLOW = query.Rows[i]["FFLOW"].ToString();
            up.setflows_FPRICE = query.Rows[i]["FPRICE"].ToString();
            up.setmenus_SFLOW = query.Rows[i]["SFLOW"].ToString();
            up.setmenus_SPRICE = query.Rows[i]["SPRICE"].ToString();
            up.setmenus_STIME = query.Rows[i]["STIME"].ToString();
            up.phoneinfo_PREMARK = query.Rows[i]["PREMARK"].ToString();
            up.userinfo_USERVICEPWD = query.Rows[i]["USERVICEPWD"].ToString();
            up.phoneinfo_PFTIME = query.Rows[i]["PFTIME"].ToString();
            up.phoneinfo_PMTIME = query.Rows[i]["PMTIME"].ToString();
            up.cruise_CUTIMEPRICE = query.Rows[i]["CUTIMEPRICE"].ToString();
            up.cruise_CUPRICE = query.Rows[i]["CUPRICE"].ToString();
            up.cruise_CUNAME = query.Rows[i]["CUNAME"].ToString();
            up.cruise_CULAST = query.Rows[i]["CULAST"].ToString();
            up.cruise_CUFLOW = query.Rows[i]["CUFLOW"].ToString();
            up.cruise_CUAREA = query.Rows[i]["CUAREA"].ToString();
            up.cruise_ID = query.Rows[i]["CUID"].ToString();

            lup.Add(up);
        }
        return lup;
    }

    [WebMethod]
    public List<UserPhone> GetTargetUserPhone(string PCODE)
    {
        List<UserPhone> lup = new List<UserPhone>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from userphone where PNO='"+PCODE+"'").Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            UserPhone up = new UserPhone();
            up.phoneinfo_ID = query.Rows[i]["ID"].ToString();
            up.phoneinfo_PBALANCE = query.Rows[i]["PBALANCE"].ToString();
            up.phoneinfo_PCRUISE = query.Rows[i]["PCRUISE"].ToString();
            up.phoneinfo_PCUID = query.Rows[i]["PCUID"].ToString();
            up.phoneinfo_PCRUISEBEGIN = query.Rows[i]["PCRUISEBEGIN"].ToString();
            up.phoneinfo_PENDTIME = query.Rows[i]["PENDTIME"].ToString();
            up.phoneinfo_PFID = query.Rows[i]["PFID"].ToString();
            up.phoneinfo_PFLOW = query.Rows[i]["PFLOW"].ToString();
            up.phoneinfo_PINITIME = query.Rows[i]["PINITIME"].ToString();
            up.phoneinfo_PNO = query.Rows[i]["PNO"].ToString();
            up.phoneinfo_PSCORE = query.Rows[i]["PSCORE"].ToString();
            up.phoneinfo_PSID = query.Rows[i]["PSID"].ToString();
            up.phoneinfo_PSTATUS = query.Rows[i]["PSTATUS"].ToString();
            up.phoneinfo_PTIME = query.Rows[i]["PTIME"].ToString();
            up.phoneinfo_PUID = query.Rows[i]["PUID"].ToString();
            up.setflows_FNAME = query.Rows[i]["FNAME"].ToString();
            up.setflows_ID = query.Rows[i]["FID"].ToString();
            up.setmenus_ID = query.Rows[i]["SID"].ToString();
            up.setmenus_SNAME = query.Rows[i]["SNAME"].ToString();
            up.userinfo_FLAG = query.Rows[i]["FLAG"].ToString();
            up.userinfo_ID = query.Rows[i]["UID"].ToString();
            up.userinfo_UADDRESS = query.Rows[i]["UADDRESS"].ToString();
            up.userinfo_UBIRTH = query.Rows[i]["UBIRTH"].ToString();
            up.userinfo_UCREATETIME = query.Rows[i]["UCREATETIME"].ToString();
            up.userinfo_UEMAIL = query.Rows[i]["UEMAIL"].ToString();
            up.userinfo_UGENDER = query.Rows[i]["UGENDER"].ToString();
            up.userinfo_UIDENDTIME = query.Rows[i]["UIDENDTIME"].ToString();
            up.userinfo_UIDNO = query.Rows[i]["UIDNO"].ToString();
            up.userinfo_UNAME = query.Rows[i]["UNAME"].ToString();
            up.setflows_FFLOW = query.Rows[i]["FFLOW"].ToString();
            up.setflows_FPRICE = query.Rows[i]["FPRICE"].ToString();
            up.setmenus_SFLOW = query.Rows[i]["SFLOW"].ToString();
            up.setmenus_SPRICE = query.Rows[i]["SPRICE"].ToString();
            up.setmenus_STIME = query.Rows[i]["STIME"].ToString();
            up.phoneinfo_PREMARK = query.Rows[i]["PREMARK"].ToString();
            up.userinfo_USERVICEPWD = query.Rows[i]["USERVICEPWD"].ToString();
            up.phoneinfo_PFTIME = query.Rows[i]["PFTIME"].ToString();
            up.phoneinfo_PMTIME = query.Rows[i]["PMTIME"].ToString();
            up.cruise_CUTIMEPRICE = query.Rows[i]["CUTIMEPRICE"].ToString();
            up.cruise_CUPRICE = query.Rows[i]["CUPRICE"].ToString();
            up.cruise_CUNAME = query.Rows[i]["CUNAME"].ToString();
            up.cruise_CULAST = query.Rows[i]["CULAST"].ToString();
            up.cruise_CUFLOW = query.Rows[i]["CUFLOW"].ToString();
            up.cruise_CUAREA = query.Rows[i]["CUAREA"].ToString();
            up.cruise_ID = query.Rows[i]["CUID"].ToString();

            lup.Add(up);
        }
        return lup;
    }

    [WebMethod]
    public List<UserPhone> GetTargetUserPhoneByID(int PID)
    {
        List<UserPhone> lup = new List<UserPhone>();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from userphone where ID=" + PID ).Tables[0];

        for (int i = 0; i < query.Rows.Count; i++)
        {
            UserPhone up = new UserPhone();
            up.phoneinfo_ID = query.Rows[i]["ID"].ToString();
            up.phoneinfo_PBALANCE = query.Rows[i]["PBALANCE"].ToString();
            up.phoneinfo_PCRUISE = query.Rows[i]["PCRUISE"].ToString();
            up.phoneinfo_PCUID = query.Rows[i]["PCUID"].ToString();
            up.phoneinfo_PCRUISEBEGIN = query.Rows[i]["PCRUISEBEGIN"].ToString();
            up.phoneinfo_PENDTIME = query.Rows[i]["PENDTIME"].ToString();
            up.phoneinfo_PFID = query.Rows[i]["PFID"].ToString();
            up.phoneinfo_PFLOW = query.Rows[i]["PFLOW"].ToString();
            up.phoneinfo_PINITIME = query.Rows[i]["PINITIME"].ToString();
            up.phoneinfo_PNO = query.Rows[i]["PNO"].ToString();
            up.phoneinfo_PSCORE = query.Rows[i]["PSCORE"].ToString();
            up.phoneinfo_PSID = query.Rows[i]["PSID"].ToString();
            up.phoneinfo_PSTATUS = query.Rows[i]["PSTATUS"].ToString();
            up.phoneinfo_PTIME = query.Rows[i]["PTIME"].ToString();
            up.phoneinfo_PUID = query.Rows[i]["PUID"].ToString();
            up.setflows_FNAME = query.Rows[i]["FNAME"].ToString();
            up.setflows_ID = query.Rows[i]["FID"].ToString();
            up.setmenus_ID = query.Rows[i]["SID"].ToString();
            up.setmenus_SNAME = query.Rows[i]["SNAME"].ToString();
            up.userinfo_FLAG = query.Rows[i]["FLAG"].ToString();
            up.userinfo_ID = query.Rows[i]["UID"].ToString();
            up.userinfo_UADDRESS = query.Rows[i]["UADDRESS"].ToString();
            up.userinfo_UBIRTH = query.Rows[i]["UBIRTH"].ToString();
            up.userinfo_UCREATETIME = query.Rows[i]["UCREATETIME"].ToString();
            up.userinfo_UEMAIL = query.Rows[i]["UEMAIL"].ToString();
            up.userinfo_UGENDER = query.Rows[i]["UGENDER"].ToString();
            up.userinfo_UIDENDTIME = query.Rows[i]["UIDENDTIME"].ToString();
            up.userinfo_UIDNO = query.Rows[i]["UIDNO"].ToString();
            up.userinfo_UNAME = query.Rows[i]["UNAME"].ToString();
            up.setflows_FFLOW = query.Rows[i]["FFLOW"].ToString();
            up.setflows_FPRICE = query.Rows[i]["FPRICE"].ToString();
            up.setmenus_SFLOW = query.Rows[i]["SFLOW"].ToString();
            up.setmenus_SPRICE = query.Rows[i]["SPRICE"].ToString();
            up.setmenus_STIME = query.Rows[i]["STIME"].ToString();
            up.phoneinfo_PREMARK = query.Rows[i]["PREMARK"].ToString();
            up.userinfo_USERVICEPWD = query.Rows[i]["USERVICEPWD"].ToString();
            up.phoneinfo_PFTIME = query.Rows[i]["PFTIME"].ToString();
            up.phoneinfo_PMTIME = query.Rows[i]["PMTIME"].ToString();
            up.cruise_CUTIMEPRICE = query.Rows[i]["CUTIMEPRICE"].ToString();
            up.cruise_CUPRICE = query.Rows[i]["CUPRICE"].ToString();
            up.cruise_CUNAME = query.Rows[i]["CUNAME"].ToString();
            up.cruise_CULAST = query.Rows[i]["CULAST"].ToString();
            up.cruise_CUFLOW = query.Rows[i]["CUFLOW"].ToString();
            up.cruise_CUAREA = query.Rows[i]["CUAREA"].ToString();
            up.cruise_ID = query.Rows[i]["CUID"].ToString();

            lup.Add(up);
        }
        return lup;
    }

    public Phoneinfo GetTargetPhone(int ID) {
        Phoneinfo p = new Phoneinfo();
        OleDB oledb = new OleDB();
        var query = oledb.getDataSet("select * from phoneinfo  where ID="+ID).Tables[0];

        p.ID = int.Parse(query.Rows[0]["ID"].ToString());
        p.PBALANCE = int.Parse(query.Rows[0]["PBALANCE"].ToString());
        p.PCRUISE = query.Rows[0]["PCRUISE"].ToString();
        p.PCRUID = int.Parse(query.Rows[0]["PCUID"].ToString());
        p.PCRUISEBEGIN = query.Rows[0]["PCRUISEBEGIN"].ToString();
        p.PENDTIME = (query.Rows[0]["PENDTIME"].ToString());
        p.PFID = int.Parse(query.Rows[0]["PFID"].ToString());
        p.PFLOW = int.Parse(query.Rows[0]["PFLOW"].ToString());
        p.PINITIME = (query.Rows[0]["PINITIME"].ToString());
        p.PNO = query.Rows[0]["PNO"].ToString();
        p.PSCORE = int.Parse(query.Rows[0]["PSCORE"].ToString());
        p.PSID = int.Parse(query.Rows[0]["PSID"].ToString());
        p.PSTATUS = query.Rows[0]["PSTATUS"].ToString();
        p.PTIME = int.Parse(query.Rows[0]["PTIME"].ToString());
        p.PUID = int.Parse(query.Rows[0]["PUID"].ToString());
        p.PREMARK = (query.Rows[0]["PREMARK"].ToString());
        p.PMTIME = (query.Rows[0]["PMTIME"].ToString());
        p.PFTIME = (query.Rows[0]["PFTIME"].ToString());

        return p;
    }

    [WebMethod]
    public void DelUser(int PID) {
        Phoneinfo p = GetTargetPhone(PID);
        int uid = p.PUID;
        OleDB oledb = new OleDB();
        oledb.executeSql("update userinfo set FLAG=0 where ID="+uid);
        oledb.executeSql("update phoneinfo set PSTATUS='冻结', PUID='-1', PSID='-1', PFID=-1, PBALANCE=0, PTIME=0, PFLOW=0, PSCORE=0, PCRUISE='否', PENDTIME='" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "' where ID=" + PID);
    }

    [WebMethod]
    public void NewRecharge(float AMOUNT,int UID,int PID,int CID,float CASH) {
        OleDB oledb = new OleDB();
        float balance = oledb.getIntegerValue("select PBALANCE from phoneinfo where ID="+ PID);
        string status = "";
        if (balance+AMOUNT>0) {
            status = "正常";
        }
        else
        {
            status = "欠费";
        }
        if (oledb.executeSql("update phoneinfo set PBALANCE=PBALANCE+" + AMOUNT + ", PSCORE=PSCORE+" + AMOUNT + ",PSTATUS='"+status+"'  where ID=" + PID)) {
            oledb.executeSql("insert into rechargerecords(RDATE,RWAY,RAMOUNT,RUID,RPID,RCID,RSCOREADD,CASH) values('"+ DateTime.Now.ToShortDateString() + " " +
                "" + DateTime.Now.ToShortTimeString() + "','柜台',"+ AMOUNT + ","+ UID + ","+ PID + ","+ CID + ","+Math.Round(AMOUNT) +","+CASH+")");
        }
    }

    [WebMethod]
    public void ScoreCharge(int PID,int AMOUNT) {
        OleDB oledb = new OleDB();
        oledb.executeSql("update phoneinfo set PBALANCE=PBALANCE+" + (AMOUNT / 100) + ", PSCORE=PSCORE-" + AMOUNT + " where ID=" + PID);
    }

    [WebMethod]
    public void ChangeSet(int PID, int SID, int UID, int CID)
    {
        OleDB oledb = new OleDB();
        if (oledb.executeSql("update phoneinfo set PSID=" + SID + "  where ID=" + PID))
        {
            oledb.executeSql("insert into business(BDATE,BCONTENT,BUID,BPID,BSID,BSMARK,BCID,BAMOUNT) values('"+ DateTime.Now.ToShortDateString() + " " +
                "" + DateTime.Now.ToShortTimeString() + "','基础套餐变更',"+UID+","+PID +","+SID+",'变更',"+CID+",0)");
        }
    }

    [WebMethod]
    public void ChangeFlow(int PID, int FID, int UID, int CID)
    {
        OleDB oledb = new OleDB();
        if (oledb.executeSql("update phoneinfo set PFID=" + FID + "  where ID=" + PID))
        {
            oledb.executeSql("insert into business(BDATE,BCONTENT,BUID,BPID,BSID,BFMARK,BCID,BAMOUNT) values('" + DateTime.Now.ToShortDateString() + " " +
                "" + DateTime.Now.ToShortTimeString() + "','流量套餐变更'," + UID + "," + PID + ","+FID+",'变更'," + CID + ",0)");
        }
    }

    [WebMethod]
    public void LockCode(string REMARK,int PID) {
        OleDB oledb = new OleDB();
        oledb.executeSql("update phoneinfo set PSTATUS='保号' , PREMARK='"+ REMARK + "', PFTIME='"+ DateTime.Now.ToShortDateString() + " " +
                "" + DateTime.Now.ToShortTimeString() + "' where ID=" + PID);
    }

    [WebMethod]
    public void MeltCode(string REMARK, int PID)
    {
        OleDB oledb = new OleDB();
        oledb.executeSql("update phoneinfo set PSTATUS='正常' , PREMARK='" + REMARK + "', PMTIME='" + DateTime.Now.ToShortDateString() + " " +
                "" + DateTime.Now.ToShortTimeString() + "' where ID=" + PID);
    }

    [WebMethod]
    public void changeUPWD(int UID,string UPWD) {
        OleDB oledb = new OleDB();
        oledb.executeSql("update userinfo set USERVICEPWD='"+UPWD+"' where ID=" + UID);
    }

    [WebMethod]
    public void AddCruise(string PCRUISE, int PCUID,string PCRUISEBEGIN,int PID)
    {
        OleDB oledb = new OleDB();      
        oledb.executeSql("update phoneinfo set PCRUISE='"+PCRUISE+ "', PCUID="+ PCUID + ", PCRUISEBEGIN='"+ PCRUISEBEGIN + "' where ID="+PID);
    }

    [WebMethod]
    public int ReflashCount() {
        OleDB oledb = new OleDB();
        oledb.executeSql("update sysmanage set ACCESSTIMES=ACCESSTIMES+1 where ID=1 ");
        return oledb.getIntegerValue("select ACCESSTIMES from sysmanage where ID=1");
    }

    [WebMethod]
    public int GetUserCount()
    {
        OleDB oledb = new OleDB();
        return oledb.getIntegerValue("select COUNT(ID) from phoneinfo where PSTATUS='正常'");
    }
}
